package com.droowa.model.dao;

import java.sql.SQLException;
import java.util.List;

import org.apache.ibatis.session.SqlSession;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.droowa.domain.MyShop;

@Repository
public class MyShopDAOMybatisImpl implements MyShopDAO{

	@Autowired
	private SqlSessionTemplate session;
	
	@Override
	public int insertMyShop(MyShop myShop) throws SQLException {
		System.out.println(myShop);
		return session.insert(makeSqlId("insertMyShop"), myShop);
	}

	@Override
	public int deleteMyShopById(String id) throws SQLException {
		return session.delete(makeSqlId("deleteMyShopById"), id) ;
	}

	@Override
	public int updateMyShop(MyShop myShop) throws SQLException {
		return session.update(makeSqlId("updateMyShop"), myShop);
	}

	
	@Override
	public MyShop selectMyShop() throws SQLException {
		return session.selectOne(makeSqlId("selectMyShop"));
	}

	private String makeSqlId(String id){
		return "droowa.myshop."+id;
	}
}
